/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 *
 */

import { ConfigJson } from '../options/configure/config-json-options.js';

export enum AbilityTypeEnum {
  PAGE = 'page',
  DATA = 'data',
  SERVICE = 'service',
  FORM = 'form',
  TEST_RUNNER = 'testrunner',
  WORKER = 'worker',
}

export namespace AbilityTypeEnum {
  export function valueOf(abilityObj: ConfigJson.AbilitiesObj): AbilityTypeEnum {
    if (abilityObj.type === 'page') {
      return AbilityTypeEnum.PAGE;
    }
    if (abilityObj.type === 'data') {
      return AbilityTypeEnum.DATA;
    }

    if (abilityObj.formsEnabled) {
      return AbilityTypeEnum.FORM;
    }
    return AbilityTypeEnum.SERVICE;
  }
}
